# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.AnalyticsHub.V1.Model.Subscription do
  @moduledoc """
  A subscription represents a subscribers' access to a particular set of published data. It contains references to associated listings, data exchanges, and linked datasets.

  ## Attributes

  *   `commercialInfo` (*type:* `GoogleApi.AnalyticsHub.V1.Model.GoogleCloudBigqueryAnalyticshubV1SubscriptionCommercialInfo.t`, *default:* `nil`) - Output only. This is set if this is a commercial subscription i.e. if this subscription was created from subscribing to a commercial listing.
  *   `creationTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. Timestamp when the subscription was created.
  *   `dataExchange` (*type:* `String.t`, *default:* `nil`) - Output only. Resource name of the source Data Exchange. e.g. projects/123/locations/US/dataExchanges/456
  *   `lastModifyTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. Timestamp when the subscription was last modified.
  *   `linkedDatasetMap` (*type:* `%{optional(String.t) => GoogleApi.AnalyticsHub.V1.Model.LinkedResource.t}`, *default:* `nil`) - Output only. Map of listing resource names to associated linked resource, e.g. projects/123/locations/US/dataExchanges/456/listings/789 -> projects/123/datasets/my_dataset For listing-level subscriptions, this is a map of size 1. Only contains values if state == STATE_ACTIVE.
  *   `linkedResources` (*type:* `list(GoogleApi.AnalyticsHub.V1.Model.LinkedResource.t)`, *default:* `nil`) - Output only. Linked resources created in the subscription. Only contains values if state = STATE_ACTIVE.
  *   `listing` (*type:* `String.t`, *default:* `nil`) - Output only. Resource name of the source Listing. e.g. projects/123/locations/US/dataExchanges/456/listings/789
  *   `logLinkedDatasetQueryUserEmail` (*type:* `boolean()`, *default:* `nil`) - Output only. By default, false. If true, the Subscriber agreed to the email sharing mandate that is enabled for DataExchange/Listing.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Output only. The resource name of the subscription. e.g. `projects/myproject/locations/US/subscriptions/123`.
  *   `organizationDisplayName` (*type:* `String.t`, *default:* `nil`) - Output only. Display name of the project of this subscription.
  *   `organizationId` (*type:* `String.t`, *default:* `nil`) - Output only. Organization of the project this subscription belongs to.
  *   `resourceType` (*type:* `String.t`, *default:* `nil`) - Output only. Listing shared asset type.
  *   `state` (*type:* `String.t`, *default:* `nil`) - Output only. Current state of the subscription.
  *   `subscriberContact` (*type:* `String.t`, *default:* `nil`) - Output only. Email of the subscriber.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :commercialInfo =>
            GoogleApi.AnalyticsHub.V1.Model.GoogleCloudBigqueryAnalyticshubV1SubscriptionCommercialInfo.t()
            | nil,
          :creationTime => DateTime.t() | nil,
          :dataExchange => String.t() | nil,
          :lastModifyTime => DateTime.t() | nil,
          :linkedDatasetMap =>
            %{optional(String.t()) => GoogleApi.AnalyticsHub.V1.Model.LinkedResource.t()} | nil,
          :linkedResources => list(GoogleApi.AnalyticsHub.V1.Model.LinkedResource.t()) | nil,
          :listing => String.t() | nil,
          :logLinkedDatasetQueryUserEmail => boolean() | nil,
          :name => String.t() | nil,
          :organizationDisplayName => String.t() | nil,
          :organizationId => String.t() | nil,
          :resourceType => String.t() | nil,
          :state => String.t() | nil,
          :subscriberContact => String.t() | nil
        }

  field(:commercialInfo,
    as:
      GoogleApi.AnalyticsHub.V1.Model.GoogleCloudBigqueryAnalyticshubV1SubscriptionCommercialInfo
  )

  field(:creationTime, as: DateTime)
  field(:dataExchange)
  field(:lastModifyTime, as: DateTime)
  field(:linkedDatasetMap, as: GoogleApi.AnalyticsHub.V1.Model.LinkedResource, type: :map)
  field(:linkedResources, as: GoogleApi.AnalyticsHub.V1.Model.LinkedResource, type: :list)
  field(:listing)
  field(:logLinkedDatasetQueryUserEmail)
  field(:name)
  field(:organizationDisplayName)
  field(:organizationId)
  field(:resourceType)
  field(:state)
  field(:subscriberContact)
end

defimpl Poison.Decoder, for: GoogleApi.AnalyticsHub.V1.Model.Subscription do
  def decode(value, options) do
    GoogleApi.AnalyticsHub.V1.Model.Subscription.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.AnalyticsHub.V1.Model.Subscription do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
